<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);

include('./phpQuery/phpQuery/phpQuery.php');

mb_internal_encoding("windows-1251");
mb_http_output("UTF-8");
ob_start("mb_output_handler");

$url = $_REQUEST["url"];
$html = file_get_contents($url); // NULL, NULL, 0, 10000);
$doc = phpQuery::newDocumentHTML($html);
$text = pq('img')->attr('src');
$n =  strpos ($text.' ', ' ', 4)-1;
$text = substr ($text,  0, (strlen($n) < 4 ? 4 : $n));
print '<div style = "float: left; width: 10px; height: 80px; overflow: hidden"></div>';
if ($text !== 'http') {
	print '<div style = "float: left; width: 70px; height: 80px; overflow: hidden">
	           <br>
               <img src="'.$url.'/'.pq('img')->attr('src').'" style = "width: 70px;"/>
           </div>';
}
else {
	print '<div style = "float: left; width: 70px; height: 80px; overflow: hidden">
<br><img src="'.pq('img')->attr('src').'" style = "width: 70px;"/></div><br>';
}
print '<div style = "float: left; width: 10px; height: 80px; overflow: hidden"></div>';
print '<div style = "float: left; width: 280px; color: #999; text-align: left;"><br><a style = "font-size: 12px; color: #222; font-weight: bold" href = "'.$url.'">'.pq('title')->html().'</a><br>';
ob_end_flush();
if (pq('meta[name="description"]')->attr('content') !== ' ') {
	print pq('meta[name="description"]')->attr('content').'<br><br></div>';
}
else {
	ob_start("mb_output_handler");
	print pq('span[class="no_current_info"]')->html().'<br><br></div>';
	} 
print '<div style = "float: left; width: 10px; height: 80px; overflow: hidden"></div>';
?>
